//
//  OrderTransportWayUseCell.m
//  StarOrangeStaff
//
//  Created by lshenrong on 2020/7/20.
//  Copyright © 2020 lshenrong. All rights reserved.
//

#import "OrderTransportWayUseCell.h"

@interface OrderTransportWayUseCell ()

@property (nonatomic,strong) UILabel *titleLbl;
@property (nonatomic,strong) CedarButton *byDayBtn; //按日租
@property (nonatomic,strong) CedarButton *bySelfBtn; //自驾
@property (nonatomic,strong) CedarButton *byPickUpBtn; //单接送

@end

@implementation OrderTransportWayUseCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if(self!=nil){
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self.contentView addSubview:self.titleLbl];
        [self.contentView addSubview:self.byDayBtn];
        [self.contentView addSubview:self.bySelfBtn];
        [self.contentView addSubview:self.byPickUpBtn];
        
        self.byDayBtn.layer.cornerRadius = self.bySelfBtn.layer.cornerRadius = self.byPickUpBtn.layer.cornerRadius = 12.5;
        
        [self.titleLbl mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.contentView).mas_offset(kMarginOffsetX);
            make.centerY.mas_equalTo(self.contentView.mas_centerY);
            make.width.mas_equalTo(70);
        }];
        
        [self.byDayBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.titleLbl.mas_right).mas_offset(kMarginOffsetX * 2);
            make.centerY.mas_equalTo(self.contentView.mas_centerY);
            make.width.mas_equalTo(60);
            make.height.mas_equalTo(25);


        }];
        
        [self.bySelfBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.byDayBtn.mas_right).mas_offset(kMarginOffsetX * 2);
            make.centerY.mas_equalTo(self.contentView.mas_centerY);
            make.width.mas_equalTo(60);
            make.height.mas_equalTo(25);


        }];
        
        [self.byPickUpBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.bySelfBtn.mas_right).mas_offset(kMarginOffsetX * 2);
            make.centerY.mas_equalTo(self.contentView.mas_centerY);
            make.width.mas_equalTo(70);
            make.height.mas_equalTo(25);


        }];
    }
    return self;
}

- (CedarButton *)byPickUpBtn{
    if (!_byPickUpBtn){
        UIColor *sColor = [UIColor colorWithRGB:0x1BBE8D];
        _byPickUpBtn =  [CedarButton buttonWithText:@"单接送" borderColor:kLightBlackColor selectedColor:sColor];
        @weakify(self)
        _byPickUpBtn.clickEvent = ^{
            @strongify(self)
            [self btnClicked:self->_byPickUpBtn];

        };
    }
    return _byPickUpBtn;
}

- (CedarButton *)byDayBtn{
    if (!_byDayBtn){
        UIColor *sColor = [UIColor colorWithRGB:0x1BBE8D];
        _byDayBtn=  [CedarButton buttonWithText:@"按天" borderColor:kLightBlackColor selectedColor:sColor];
        @weakify(self)
        _byDayBtn.clickEvent = ^{
            @strongify(self)
            [self btnClicked:self->_byDayBtn];

        };
    }
    return _byDayBtn;
}

- (CedarButton *)bySelfBtn{
    if (!_bySelfBtn){
        UIColor *sColor = [UIColor colorWithRGB:0x1BBE8D];
        _bySelfBtn =  [CedarButton buttonWithText:@"按月" borderColor:kLightBlackColor selectedColor:sColor];
        @weakify(self)
        _bySelfBtn.clickEvent = ^{
            @strongify(self)
            [self btnClicked:self->_bySelfBtn];
        };
    }
    return _bySelfBtn;
}


- (void)btnClicked:(UIButton *)sender{
    for (UIButton *button in self.contentView.subviews) {
        if ([button isMemberOfClass:[CedarButton class]]) {
            button.selected = NO;
        }
    }
    sender.selected = YES;
}
MACRO_UILabel_LazyloadWithPFCGFont(titleLbl, @"用车方式", kBlackColor, 15)



@end
